<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">


    <ui:define name="content">    

        <h:panelGroup rendered="true" >
            <h:form>
                <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
                <p:panel id="reportPrint" styleClass="noBorder summeryBorder">
                    <f:facet name="header">

                        <p:commandButton id="btnRefresh" ajax="false" 
                                         value="Process" 
                                         styleClass="noPrintButton" 
                                         style="float: right;" 
                                         actionListener="#{channelReportTempController.createChannelCountByUserOrDate()}" />  
                        <p:defaultCommand target="btnRefresh"/>

                        <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="reportPrint" />
                        </p:commandButton>  

                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;">
                            <pe:exporter type="xlsx" target="tbl" fileName="All_Cashier_Summery_Detail_Report" subTable="true"/>
                        </p:commandButton>  

                        <h:outputLabel value="Cashier Vise Count Report"/><br/>
<!--                        <h:outputLabel value="#{sessionController.loggedUser.institution.name}"/> -->


                        <h:outputLabel value="From :"/>
                        <h:outputLabel value="#{channelReportTempController.fromDate}">
                            <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a"/>
                        </h:outputLabel>
                        <h:outputLabel value="&emsp;&emsp;To :"/>
                        <h:outputLabel value="#{channelReportTempController.toDate}">
                            <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a"/>
                        </h:outputLabel><br/>

                    </f:facet>
                    <f:facet name="footer">
                        <h:outputLabel style="float: right" value="Printed By : #{sessionController.loggedUser.webUserPerson.name}" />
                    </f:facet>
                    <h:panelGrid columns="2"  styleClass="noPrintButton">

                        <h:outputLabel value="From Date" />
                        <p:calendar id="frmDate" value="#{channelReportTempController.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss"  >
                        </p:calendar>
                        <h:outputLabel value="To Date"/>
                        <p:calendar id="toDate" value="#{channelReportTempController.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss">
                        </p:calendar>
                        <p:outputLabel value="Channel Type" rendered="#{sessionController.loggedPreference.applicationInstitution eq 'Cooperative'}" />
                        <p:selectOneMenu id="cmbChanType" value="#{channelReportTempController.reportKeyWord.billType}" rendered="#{sessionController.loggedPreference.applicationInstitution eq 'Cooperative'}" >
                            <f:selectItem itemLabel="Please Select a Type"/>
                            <f:selectItems value="#{enumController.channelType}" var="t" itemLabel="#{t.label}" itemValue="#{t}" />    
                        </p:selectOneMenu>
                        <h:outputLabel value="With Agency"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.agency}" />
                        <h:outputLabel value="By Date"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.byDate}" />
                    </h:panelGrid>
                    <br/>
                    <p:dataTable id="tbl" value="#{channelReportTempController.channelSummeryDateRangeOrUserRows}" var="csh" rendered="#{!channelReportTempController.byDate}">

                        <p:columnGroup type="header">
                            <p:row>
                                <p:column headerText="Date"/>
                                <p:column headerText="Billed"/>
                                <p:column headerText="Canceled"/>
                                <p:column headerText="Refunded"/>
                                <p:column headerText="Total Count"/>
                                <p:column headerText="Doc Fee"/>
                                <p:column headerText="Hos Fee"/>
                                <p:column headerText="Total"/>
                            </p:row>
                        </p:columnGroup>


                        <p:subTable value="#{csh.dateRangeRows}" var="dt"  rendered="#{csh.dateRangeRows.size()>0}"
                                    >

                            <f:facet name="header">
                                <h:outputLabel value="#{csh.user.webUserPerson.name}"/>
                            </f:facet>
                            
                            <p:column>
                                <h:outputLabel value="#{dt.date}" style="#{dt.bold?'font-weight: bold':''}"></h:outputLabel>
                                <h:outputLabel value="Total" rendered="#{dt.date eq null}" style="#{dt.bold?'font-weight: bold':''}"></h:outputLabel>
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.billCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.canceledCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.refundCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>                                
                            </p:column>
                            
                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.billCount-dt.canceledCount-dt.refundCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>                                
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.totalDocFee}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.totalHosFee}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.totalDocFee+dt.totalHosFee}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>
                        </p:subTable>
                        <p:columnGroup type="footer">
                            <p:row>

                                <p:column footerText="Grant Total">

                                </p:column>

                                <p:column footerText="#{channelReportTempController.channelTotal.totalBillCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalBillCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{channelReportTempController.channelTotal.totalCanceledCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalCanceledCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalRefundCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalRefundCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalBillCount-channelReportTempController.channelTotal.totalCanceledCount-channelReportTempController.channelTotal.totalRefundCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalBillCount-channelReportTempController.channelTotal.totalCanceledCount-channelReportTempController.channelTotal.totalRefundCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{channelReportTempController.channelTotal.totalDocFee}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalDocFee}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalHosFee}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalHosFee}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalDocFee+channelReportTempController.channelTotal.totalHosFee}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalDocFee+channelReportTempController.channelTotal.totalHosFee}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>
                    
                    <p:dataTable id="tbl2" value="#{channelReportTempController.channelSummeryDateRangeOrUserRows}" var="csh" rendered="#{channelReportTempController.byDate}">

                        <p:columnGroup type="header">
                            <p:row>
                                <p:column headerText="Date"/>
                                <p:column headerText="Billed"/>
                                <p:column headerText="Canceled"/>
                                <p:column headerText="Refunded"/>
                                <p:column headerText="Total Count"/>
                                <p:column headerText="Doc Fee"/>
                                <p:column headerText="Hos Fee"/>
                                <p:column headerText="Total"/>
                            </p:row>
                        </p:columnGroup>


                        <p:subTable value="#{csh.userRows}" var="dt"  rendered="#{csh.userRows.size()>0}"
                                    >

                            <f:facet name="header">
                                <h:outputLabel value="#{csh.date}"/>
                            </f:facet>
                            
                            <p:column>
                                <h:outputLabel value="#{dt.user.webUserPerson.name}" style="#{dt.bold?'font-weight: bold':''}"></h:outputLabel>
                                <h:outputLabel value="Total" rendered="#{dt.user eq null}" style="#{dt.bold?'font-weight: bold':''}"></h:outputLabel>
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.billCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.canceledCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.refundCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>                                
                            </p:column>
                            
                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.billCount-dt.canceledCount-dt.refundCount}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0" />
                                </h:outputLabel>                                
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.totalDocFee}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.totalHosFee}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>

                            <p:column styleClass="averageNumericColumn">
                                <h:outputLabel value="#{dt.totalDocFee+dt.totalHosFee}" style="#{dt.bold?'font-weight: bold':''}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>
                        </p:subTable>
                        
                        <p:columnGroup type="footer">
                            <p:row>

                                <p:column footerText="Grant Total">

                                </p:column>

                                <p:column footerText="#{channelReportTempController.channelTotal.totalBillCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalBillCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{channelReportTempController.channelTotal.totalCanceledCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalCanceledCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalRefundCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalRefundCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalBillCount-channelReportTempController.channelTotal.totalCanceledCount-channelReportTempController.channelTotal.totalRefundCount}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalBillCount-channelReportTempController.channelTotal.totalCanceledCount-channelReportTempController.channelTotal.totalRefundCount}">
                                            <f:convertNumber pattern="#,##0" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{channelReportTempController.channelTotal.totalDocFee}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalDocFee}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalHosFee}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalHosFee}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column footerText="#{channelReportTempController.channelTotal.totalDocFee+channelReportTempController.channelTotal.totalHosFee}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{channelReportTempController.channelTotal.totalDocFee+channelReportTempController.channelTotal.totalHosFee}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>
                    
                </p:panel>  
            </h:form>

        </h:panelGroup>
    </ui:define>

</ui:composition>
